package cn.itsource.controller;

import cn.itsource.domain.Log;
import cn.itsource.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/log")
public class logController {

    @Autowired
    private LogService logService;

    //查询log表所有数据
    @RequestMapping("/list")
    public String list(Model model) {
        List<Log> logList = logService.findAll();
        model.addAttribute("logs", logList);
        return "log/logList";
    }

    //根据id删除log表的一条数据
    @RequestMapping("/delete")
    public String del(Integer id) {
        logService.delete(id);
        return "redirect:/log/list";
    }

    //根据id查询log表中的一条数据
    @RequestMapping("/view")
    public String view(Integer id, Model model) {
        Log logServiceOne = logService.findOne(id);
        model.addAttribute("log", logServiceOne);
        return "log/logView";
    }
}
